package com.qf.agro.controller;

import com.qf.agro.common.ResultInfo;
import com.qf.agro.pojo.FacilitiesCategory;
import com.qf.agro.service.FacilitiesCategoryService;
import org.apache.poi.hssf.util.HSSFColor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 10202
 * @version V1.0
 * @Project smart-agriculture-parent
 * @Package com.qf.agro.controller
 * @Date 2023/7/3 17:49
 */
@RestController
public class FacilitiesCategoryController {

    @Autowired
    private FacilitiesCategoryService facilitiesCategoryService;

    @GetMapping("facilities/category/page")
    public ResultInfo getpage(@RequestParam(value = "page",defaultValue = "1") Long page,@RequestParam Long pageSize,String name){


        return facilitiesCategoryService.getPage(page,pageSize,name);
    }

    @PostMapping("facilities/category")
    public ResultInfo insertMessage(@RequestBody FacilitiesCategory facilitiesCategory)
    {

        return facilitiesCategoryService.save(facilitiesCategory);
    }

    @DeleteMapping("facilities/category")
    public ResultInfo DeleteCategory(Long id){

        return facilitiesCategoryService.deleteById(id);
    }

    @PutMapping("facilities/category")
    public ResultInfo updateCategory(FacilitiesCategory facilitiesCategory){

        facilitiesCategoryService.update(facilitiesCategory);
        return ResultInfo.success("修改成功");
    }
}
